package com.mtsmda.study.spring.spring_core.run;

import java.util.ArrayList;
import java.util.List;

import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

import com.mtsmda.study.spring.spring_core.bean_basic.CollectionsExample;
import com.mtsmda.study.spring.spring_core.bean_basic.Customer;
import com.mtsmda.study.spring.spring_core.bean_basic.FIOPerson;
import com.mtsmda.study.spring.spring_core.bean_basic.FileNameGenerator;
import com.mtsmda.study.spring.spring_core.bean_basic.Message;
import com.mtsmda.study.spring.spring_core.bean_basic.PersonInfo;
import com.mtsmda.study.spring.spring_core.bean_basic.SpringCreateList;
import com.mtsmda.study.spring.spring_core.bean_basic.SpringCreateMap;
import com.mtsmda.study.spring.spring_core.bean_basic.SpringCreateSet;
import com.mtsmda.study.spring.spring_core.bean_basic.annotation.ServiceS;
import com.mtsmda.study.spring.spring_core.di.FIO;
import com.mtsmda.study.spring.spring_core.di.file.FileHelper;

public class RunApp {

	@SuppressWarnings("resource")
	public static void main(String[] args) {
		ApplicationContext context = new ClassPathXmlApplicationContext(
				new String[] { "/springBeanSecond/SpringBeanPerson.xml",
						"SpringBeans.xml",
						"/springBeanSecond/SpringBeanService.xml",
						"/springBeanSecond/SpringBeanCreateList.xml",
						"/springBeanSecond/SpringBeanCreateSet.xml",
						"/springBeanSecond/SpringBeanCreateMap.xml",
						"/springBeanSecond/SpringBeanDateInject.xml",
						"/springBeanSecond/SpringBeanPropertiesFile.xml" });

		FIO fio = (FIO) context.getBean("fio");
		System.out.println(fio.toString());

		FIO fio2 = (FIO) context.getBean("fio2");
		System.out.println(fio2.getImya());

		FIO fio3 = (FIO) context.getBean("fio3");
		System.out.println(fio3);

		FileHelper fileHelper = (FileHelper) context.getBean("fileChoose");
		fileHelper.getFileI().getFileFormat();

		FileNameGenerator fileNameGenerator = (FileNameGenerator) context
				.getBean("fileNameGenerator");
		fileNameGenerator.getFile();

		PersonInfo personInfo = (PersonInfo) context.getBean("personInfo");
		System.out.println(personInfo.getFio().getFIO());
		System.out.println(personInfo.getPersonInfo());

		System.out.println("*******SCOPE*********");

		Message message = (Message) context.getBean("message");
		message.setMessage("My message");
		System.out.println(message.getMessage());

		Message message2 = (Message) context.getBean("message");
		System.out.println(message2.getMessage());

		ServiceS serviceS = (ServiceS) context.getBean("service");
		serviceS.setNameService("HTTP");
		System.out.println(serviceS.getNameService());

		System.out.println("*******Collection*************");
		CollectionsExample collectionsExample = (CollectionsExample) context
				.getBean("collectionsE");
		System.out.println(collectionsExample.toString());

		SpringCreateList springCreateList = (SpringCreateList) context
				.getBean("springCreateList");
		System.out.println(springCreateList.toString());

		System.out.println("\n\n");

		SpringCreateSet springCreateSet = (SpringCreateSet) context
				.getBean("springCreateSet");
		System.out.println(springCreateSet.toString());

		SpringCreateMap springCreateMap = (SpringCreateMap) context
				.getBean("springCreateMap");
		System.out.println(springCreateMap.toString());

		System.out.println("******Date inject********");
		FIOPerson fioPerson = (FIOPerson) context.getBean("injectDate");
		System.out.println(fioPerson.toString());

		System.out.println("*****Inheritance******");
		Customer customer = (Customer) context.getBean("steepCustomer");
		System.out.println(customer.toString());

		System.out.println("*********Check************");
		
		Customer customer2 = (Customer)context.getBean("simpleCustomer");
		System.out.println(customer2.toString());
		
		/*
		 * FIOPerson fioPerson2 = (FIOPerson) context.getBean("injectDate2");
		 * System.out.println(fioPerson2.toString());
		 */
		/*
		 * List<String> strings = new ArrayList<String>();
		 * strings.add("Dmitrii");
		 * System.out.println(strings.get(0).getClass().getCanonicalName());
		 */
		/*
		 * First first = (First) context.getBean("first");
		 * System.out.println(first.getName());
		 * 
		 * // ----- 1 IOutputGenerator iOutputGenerator = new
		 * CSVOutputGenerator(); iOutputGenerator.generateOutput();
		 * iOutputGenerator = new JSONOutputGenerator();
		 * iOutputGenerator.generateOutput();
		 * 
		 * OutputHelper outputHelper = new OutputHelper();
		 * outputHelper.generate(); outputHelper = new OutputHelper(new
		 * JSONOutputGenerator()); outputHelper.generate();
		 * 
		 * // ----- 2 System.out.println("*****");
		 * 
		 * OutputHelper outputHelper2 = (OutputHelper) context
		 * .getBean("outputHelper"); outputHelper2.generate();
		 */

		/*
		 * ApplicationContext context2 = new AnnotationConfigApplicationContext(
		 * FirstApp.class); HelloWorld helloWorld = (HelloWorld)
		 * context2.getBean("helloWorld");
		 * 
		 * CustomerBO customerBO = (CustomerBO) context2.getBean("customerBO");
		 * customerBO.printMessage("Hello customer");
		 * 
		 * ScheldulerBO scheldulerBO = (ScheldulerBO)
		 * context2.getBean("scheldulerBO");
		 * scheldulerBO.printMessage("Hello schelduler");
		 */

	}

}